import React from 'react';
import Modal from './Modal.jsx';

export default class App extends React.Component {
    constructor (props) {
        super(props);
        this.state = {
            count: 0
        };
    }

    render () {
        return (
            <div>
                <div>{this.state.count}</div>
                {/* 将点击方法传递给子组件, 让子组件调用父组件的方法 */}
                <Modal onClick={() => {this.setState((state) => ({ count: state.count + 1 }));}} />
            </div>
        );
    }
}
